﻿<template>
  <section>
    <div class="bar">
      <el-button
        type="text"
        v-for="(item, index) in list"
        :key="index"
        @click="handleControl(item.model)"
      >
        <span
          v-if="item.type == 'card'"
          class="bar-card"
          @mouseover="handleStatus1(index)"
          @mouseout="handleStatus0(index)"
        >
          <img
            :src="
              require(`@/assets/icon/icon-${item.model}${
                item.status != 0 ? item.status : ''
              }.png`)
            "
            alt=""
          />
          <span>{{ item.label }}</span>
        </span>
        <span
          v-else
          @mouseover="handleStatus1(index)"
          @mouseout="handleStatus0(index)"
        >
          <span class="bar-path">{{ item.label }}</span>
          <img
            :src="require(`@/assets/icon/icon-${item.model}${
                item.status != 0 ? item.status : ''
              }.png`)"
            alt=""
            v-if="item.type == 'img'"
          />
          <span v-if="item.type != 'path'" class="bar-text">{{
            obj[item.model]
          }}</span>
        </span>
      </el-button>
    </div>
  </section>
</template>

<script>
export default {
  name: "comControlBar1",
  components: {},
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
    width: {
      type: String,
      default: "360px",
    },
    obj: {
      type: Object,
      default: () => {
        return {};
      },
    },
    align: {
      type: String,
      default: "right",
    },
    textColor: {
      type: String,
      default: "#888",
    },
  },
  computed: {},
  watch: {},
  data() {
    return {
      activeTab: null,
    };
  },
  mounted() {},
  methods: {
    handleControl(v) {
      this.$emit("control", v);
    },
    handleStatus1(v) {
      this.$emit("status1", v);
    },
    handleStatus0(v) {
      this.$emit("status0", v);
    },
  },
};
</script>

<style scoped lang="less">
.bar {
  padding-right: 3px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  > button {
    padding: 0;
    margin-left: 0;
    margin-right: 10px;
    .bar-card {
      font-size: 12px;
      color: #555;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      margin-right: 20px;
      width: 30px;
      img {
        margin-bottom: 8px;
      }
    }
    .bar-path {
      font-family: "AdobeHeitiStd-Regular";
      font-size: 12px;
      margin-right: 2px;
    }
    .bar-text {
      font-family: "AdobeHeitiStd-Regular";
      font-size: 12px;
      margin-right: 2px;
    }
    &:hover {
      .bar-card {
        color: #2f82ff;
      }
      .bar-path {
        color: #2f82ff;
      }
      .bar-text {
        color: #2f82ff;
      }
    }
  }
}
</style>